#include "RPCCode.h"

int RPCClient::RPCConnect(){
	
	
	// Creates a string binding handle.
	// This function is nothing more than a printf.
	// Connection is not done here.
	status = RpcStringBindingCompose(
		NULL, // UUID to bind to.
		reinterpret_cast<unsigned char*>("ncacn_ip_tcp"), // Use TCP/IP
													// protocol.
		reinterpret_cast<unsigned char*>("localhost"), // TCP/IP network
													// address to use.
		reinterpret_cast<unsigned char*>("4747"), // TCP/IP port to use.
		NULL, // Protocol dependent network options to use.
		&szStringBinding); // String binding output.

	if (status)
		exit(status);

	// Validates the format of the string binding handle and converts
	// it to a binding handle.
	// Connection is not done here either.
	status = RpcBindingFromStringBinding(
		szStringBinding, // The string binding to validate.
		&hRemoteCallBinding); // Put the result in the implicit binding
						// handle defined in the IDL file.

	if (status)
		exit(status);

	return 0;
}

int RPCClient::RPCCleanup(){
	// Free the memory allocated by a string.
	status = RpcStringFree(
		&szStringBinding); // String to be freed.

	if (status)
		exit(status);

	// Releases binding handle resources and disconnects from the server.
	status = RpcBindingFree(
		&hRemoteCallBinding); // Frees the implicit binding handle defined in
						// the IDL file.

	if (status)
		exit(status);


	return 0;
}